Show widget file path in inspector - #9972
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the display of a widget's creation source location (file name, line, and column) in the DevTools Inspector. It updates the InspectorController to fetch this information from the details subtree, adds a new WidgetCreationLocationHeader widget to display it, and includes corresponding unit tests. The review feedback highlights a potential crash if the controller is disposed during an asynchronous operation, suggests a defensive null check for the node ID in getDetailsSubtree, and recommends using a null-assertion operator to satisfy strict null safety in the creation location header.
e7abfc7 to
f360e4a
Compare
|
Instead of making it a header above the properties tab view, let's add it to the tab view directly by setting the
|
|
Makes sense -- moved it to the trailing widget. Done! |
|
Updated PR description.. |
| _widgetPropertiesTab = DevToolsTab.create( | ||
| tabName: 'Widget properties', | ||
| gaPrefix: DetailsTable.gaPrefix, | ||
| trailing: WidgetCreationLocationTrailing(controller: widget.controller), |
There was a problem hiding this comment.
This trailing widget should probably be on all tabs, not just the properties tab.
If you update the AnalyticsTabbedView constructor to this, then you can set the trailingWidgets property directly in the AnalyticsTabbedView constructor, and revert the changes to _widgetPropertiesTab.
AnalyticsTabbedView({
super.key,
required this.tabs,
required this.gaScreen,
this.sendAnalytics = true,
this.onTabChanged,
this.initialSelectedIndex,
this.analyticsSessionIdentifier,
this.staticSingleTab = false,
List<Widget> trailingWidgets = const [],
}) : trailingWidgets = [
...List.generate(
tabs.length,
(index) => tabs[index].tab.trailing ?? const SizedBox(),
),
...trailingWidgets,
];There was a problem hiding this comment.
Done -- path is on all tabs now via trailingWidgets.
Issue #9922
This PR fixes issue #9922 where the new Flutter Inspector didn’t show the widget’s file path like the legacy inspector did. You could select a widget and see layout/properties on the right, but there was no
main.dart:line:columnanywhere — the summary tree is loaded without full details, socreationLocationnever showed up in the UI.How I fixed it:
Basically, when a widget is selected we fetch a small details subtree for just that node, read
creationLocation, and showfilename.dart:line:columnabove the properties tabs. The widget tree load stays the same so we don’t pull full details for every node.before --

after --

Pre-launch Checklist
General checklist
///).Issues checklist
contributions-welcomeorgood-first-issuelabel.contributions-welcomeorgood-first-issuelabel. I understand this means my PR might take longer to be reviewed.Tests checklist
AI-tooling checklist
Feature-change checklist
release-notes-not-requiredlabel or left a comment requesting the label be added.packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.If you need help, consider asking for help on Discord.